package com.project.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("user")
public class UserController {
    @RequestMapping("login")
    public String login(String userName, String pwd,
                        String userCode, HttpServletRequest req){
        //从session中，得到验证码
        String code = (String)req.getSession().getAttribute("checkCode");
        if(code.equalsIgnoreCase(userCode) == false){
            return "验证码错误";
        }
        else if("java".equals(userName) && "123".equals(pwd)){
            return "ok";
        }
        else {
            return "no";
        }
    }
}
